<template>
  <div class="prs-process-box" v-loading="loading">
    <el-form ref="fmData" :model="fmData" :rules="rules" v-if="fmData != null">
      <div class="purchas-information">
        <el-card class="box-card">
          <div slot="header" class="unfold-way">
            <p>工艺路线</p>
            <div class="button-plan">
              <span
                v-if="
                  fmStatus == 'seeStatus' && $route.query.open !== 'addStatus'
                "
              >
                <el-button
                  @click="btnAdd('view')"
                  type="primary"
                  v-hasPermi="['prs:process:entity:add']"
                  :disabled="option.stripStatus"
                >
                  新增</el-button
                >
              </span>
              <span
                v-if="
                  fmStatus == 'seeStatus' && $route.query.open == 'addStatus'
                "
              >
                <el-button
                  @click="btnAdd('add')"
                  type="primary"
                  v-hasPermi="['prs:process:entity:add']"
                  :disabled="option.stripStatus"
                  v-if="fmStatus == 'seeStatus'"
                >
                  新增</el-button
                >
              </span>
              <span v-if="fmStatus == 'updateStatus'">
                <el-button
                  type="primary"
                  @click="btnSave(fmData)"
                  :disabled="option.btnIsClick || fmStatus !== 'updateStatus'"
                  v-hasPermi="['prs:process:entity:edit']"
                  >保存
                </el-button>
                <el-button type="succes" @click="btnUndo">撤回</el-button>
              </span>
              <span v-if="fmStatus == 'addStatus'">
                <el-button
                  type="primary"
                  v-hasPermi="['prs:process:entity:add']"
                  @click="btnNew(fmData)"
                  :disabled="option.btnIsClick"
                  >保存</el-button
                >
              </span>
              <span>
                <el-button
                  type="succes"
                  v-if="fmStatus == 'seeStatus'"
                  v-hasPermi="['prs:process:entity:edit']"
                  @click="btnEdit"
                  :disabled="
                    fmData.invoiceStatus == '1' || fmStatus !== 'seeStatus'
                  "
                  >编辑</el-button
                >
                <el-button
                  type="succes"
                  v-if="fmStatus == 'addStatus'"
                  @click="btnCancel"
                  >取消</el-button
                >
                <el-button
                  type="success"
                  v-hasPermi="['prs:process:permit']"
                  @click="btnCheck"
                  :disabled="
                    fmStatus !== 'seeStatus' ||
                    fmData.invoiceStatus == '1' ||
                    fmData.invoiceStatus == '2'
                  "
                >
                  审核</el-button
                >
                <el-button
                  type="info"
                  v-hasPermi="['prs:process:revoke']"
                  @click="btnUnCheck"
                  :disabled="
                    fmStatus !== 'seeStatus' ||
                    fmData.invoiceStatus == '0' ||
                    fmData.invoiceStatus == '2'
                  "
                  >反审核
                </el-button>
              </span>
              <span>
                <el-button
                  type="success"
                  plain
                  icon="el-icon-printer"
                  size="mini"
                  @click="objPrinter.handlePrint()"
                  v-hasPermi="['prs:process:print']"
                  v-if="fmStatus == 'seeStatus'"
                  >打印</el-button
                >
              </span>
              <span>
                <el-button
                  type="text"
                  @click="objHelper.downToggle()"
                  style="padding: 0"
                  >{{ style.downTitle }}</el-button
                >
              </span>
            </div>
          </div>
          <collapseTransition>
            <div class="info-list" v-show="style.isToggle" ref="toggleBox">
              <div class="wn-in-box">
                <div class="list-box" style="z-index: 2; background: #fff">
                  <div class="box-input mt-box">
                    <p>单据编码：</p>
                    <el-form-item prop="processCode">
                      <div class="box-add">
                        <el-input v-model="fmData.processCode" disabled>
                        </el-input>
                      </div>
                    </el-form-item>
                  </div>
                  <div class="box-input">
                    <p>工艺名称：</p>
                    <el-form-item prop="name">
                      <el-input
                        v-model="fmData.name"
                        :disabled="option.disabledInput"
                      >
                      </el-input>
                    </el-form-item>
                  </div>
                  <div class="box-input">
                    <p>单据日期：</p>
                    <el-form-item prop="invoiceDate">
                      <el-date-picker
                        class="input-data"
                        type="date"
                        :disabled="option.disabledInput"
                        placeholder="选择日期"
                        v-model="fmData.invoiceDate"
                        style="width: 100%"
                      >
                      </el-date-picker>
                    </el-form-item>
                  </div>
                </div>

                <div
                  class="list-box"
                  :class="{ 'hide-box-x': style.extendStatus }"
                >
                  <div
                    class="tran-box"
                    :class="{ 'hide-box-w': style.extendStatus }"
                  >
                    <div class="box-input">
                      <p>操作员：</p>
                      <el-form-item>
                        <el-input v-model="fmData.userOper" disabled>
                        </el-input>
                      </el-form-item>
                    </div>
                    <div class="box-input">
                      <p>审核员：</p>
                      <el-form-item>
                        <el-input v-model="fmData.userCheck" disabled>
                        </el-input>
                      </el-form-item>
                    </div>
                    <div class="box-input">
                      <p>审核日期：</p>
                      <el-form-item prop="checkDate">
                        <el-date-picker
                          class="input-data"
                          type="date"
                          v-model="fmData.checkDate"
                          style="width: 100%"
                          disabled
                        ></el-date-picker>
                      </el-form-item>
                    </div>
                  </div>
                </div>
                <div class="list-box">
                  <div class="box-input blue-color">
                    <p>单据状态：</p>
                    <div class="invoice-box">
                      <span
                        v-if="fmData.invoiceStatus == '0'"
                        style="color: #e6a23c"
                        >{{ fmData.invoiceStatus | getInvoice }}</span
                      >
                      <span
                        v-if="fmData.invoiceStatus == '1'"
                        style="color: #67c23a"
                        >{{ fmData.invoiceStatus | getInvoice }}</span
                      >
                      <span
                        v-if="fmData.invoiceStatus == '2'"
                        style="color: #909399"
                        >{{ fmData.invoiceStatus | getInvoice }}</span
                      >
                    </div>
                  </div>
                  <div class="box-input">
                    <p>排序：</p>
                    <el-form-item>
                      <el-input
                        v-model="fmData.orderId"
                        :disabled="option.disabledInput"
                      />
                    </el-form-item>
                  </div>
                  <div class="box-input">
                    <p>备注：</p>
                    <el-form-item>
                      <el-input
                        type="textarea"
                        autosize
                        v-model="fmData.remarks"
                        :disabled="option.disabledInput"
                      >
                      </el-input>
                    </el-form-item>
                  </div>
                </div>
              </div>
              <div class="articles-numbers" v-if="fmStatus == 'seeStatus'">
                <el-link
                  type="success"
                  v-hasPermi="['prs:process:next']"
                  @click="btnForward(fmData.processCode, 'last')"
                  :disabled="option.stripStatus"
                  >上一条
                </el-link>
                <el-link
                  type="success"
                  v-hasPermi="['prs:process:next']"
                  @click="btnForward(fmData.processCode, 'next')"
                  :disabled="option.stripStatus"
                  >下一条
                </el-link>
              </div>
            </div>
          </collapseTransition>
        </el-card>
      </div>
      <div class="purchas-content">
        <el-card class="box-card">
          <!-- 标准工序 -->
          <div>
            <div class="mb-mbom">
              <div slot="header" class="unfold-way">
                <p>标准工序</p>
                <div style="padding-bottom: 7px">
                  <div
                    v-if="fmStatus == 'addStatus' || fmStatus == 'updateStatus'"
                  >
                    <el-button
                      type="warning"
                      plain
                      icon="el-icon-download"
                      @click="objFilling.operateView()"
                    >
                      引入</el-button
                    >
                  </div>
                </div>
              </div>
              <div class="info-table">
                <div class="table-data link-out-side">
                  <el-table
                    :data="fmData.prsProcessSectionList"
                    border
                    :height="style.tableHeight"
                    row-key="id"
                    style="width: 100%"
                    ref="tableClums"
                  >
                    <template slot="empty">
                      <span></span>
                    </template>
                    <el-table-column
                      type="index"
                      width="40"
                      label="序号"
                      :key="1"
                    >
                    </el-table-column>
                    <el-table-column label="工序代码">
                      <template slot-scope="scope">
                        <el-form-item>
                          <el-input v-model="scope.row.code" disabled>
                          </el-input>
                        </el-form-item>
                      </template>
                    </el-table-column>
                    <el-table-column label="工序名称">
                      <template slot-scope="scope">
                        <el-form-item>
                          <el-input v-model="scope.row.name" disabled>
                          </el-input>
                        </el-form-item>
                      </template>
                    </el-table-column>
                    <el-table-column label="标准工时">
                      <template slot-scope="scope">
                        <el-form-item>
                          <el-input
                            v-model="scope.row.duration"
                            :disabled="option.disabledInput"
                          >
                          </el-input>
                        </el-form-item>
                      </template>
                    </el-table-column>
                    <el-table-column label="是否质检">
                      <template slot-scope="scope">
                        <el-form-item>
                          <el-select
                            v-model="scope.row.isQuality"
                            placeholder=""
                            :disabled="option.disabledInput"
                          >
                            <el-option label="是" value="1"> </el-option>
                            <el-option label="否" value="0"> </el-option>
                          </el-select>
                        </el-form-item>
                      </template>
                    </el-table-column>
                    <el-table-column label="计件方式">
                      <template slot-scope="scope">
                        <el-form-item>
                          <el-select
                            v-model="scope.row.countType"
                            placeholder=""
                            :disabled="option.disabledInput"
                          >
                            <el-option label="班组" value="0"> </el-option>
                            <el-option label="个人" value="1"> </el-option>
                          </el-select>
                        </el-form-item>
                      </template>
                    </el-table-column>
                    <el-table-column label="排序">
                      <template slot-scope="scope">
                        <el-form-item>
                          <el-input
                            v-model="scope.row.orderId"
                            :disabled="option.disabledInput"
                          >
                          </el-input>
                        </el-form-item>
                      </template>
                    </el-table-column>
                    <el-table-column
                      label="操作"
                      width="80"
                      v-if="
                        fmStatus == 'addStatus' || fmStatus == 'updateStatus'
                      "
                      :key="16"
                    >
                      <template slot-scope="scope">
                        <div class="operation-btn">
                          <el-link
                            type="danger"
                            plain
                            @click="
                              objMaterial.deleteList(scope.row, scope.$index)
                            "
                            >删除
                          </el-link>
                        </div>
                      </template>
                    </el-table-column>
                  </el-table>
                </div>
              </div>
            </div>
          </div>
        </el-card>
      </div>
    </el-form>
    <!-- 选择标准工序 -->
    <selectOperate
      :selectOperateDialog="stack.prsStatus"
      @handleOperateSelect="objFilling.handleOperateSelect(arguments)"
      v-if="stack.prsStatus"
      @selectOperateClose="objFilling.selectOperateClose()"
    />

    <!-- 打印数据 -->
    <PrintPage
      :printData="print.printData"
      :qrCodeValue="print.qrCodeValue"
      v-if="print.printStatus"
      ref="startPrint"
      :title="print.printTitle"
    />
    <div ref="file"></div>
  </div>
</template>

<script>
//接口
import {
  dictMatching, //系统字典
  addBill, //新增单据
  seeBill, //查看单据
  updateBill, //更新单据
  NextBill, //上一条下一条
  examineBill, //审核单据
  examineDeBill, //反审核单据
  moduleParameters,
} from "../../api/process";
//并行请求
import axios from "axios";
//输入是否为数字效验
import { isAccord } from "@/utils/cingsoft";
// 物料选择组件
import selectMaterial from "../../components/Common/selectMaterial.vue";
//选择引入物料组件
import selectImportMaterial from "./selectImportMaterial.vue";
//标准工序
import selectOperate from "./selectOperate";
//打印组件
import PrintPage from "../../components/Order/print";
export default {
  data() {
    // 时长输入效验
    var checkOutDuration = (rule, value, callback) => {
      if (!value) {
        return callback(new Error(""));
      }
      if (!isAccord(value)) {
        callback(new Error(""));
      } else {
        callback();
      }
    };

    // 弹框时长输入效验
    var checkOutDuration2 = (rule, value, callback) => {
      if (!this.stack.formArrangeDate.duration) {
        return callback(new Error(""));
      }
      if (!isAccord(this.stack.formArrangeDate.duration)) {
        callback(new Error(""));
      } else {
        callback();
      }
    };

    // 弹框日期效验
    var checkOutArrangeDate2 = (rule, value, callback) => {
      if (!this.stack.formArrangeDate.arrangeDate) {
        return callback(new Error(""));
      } else {
        callback();
      }
    };

    // 数量输入效验
    var checkOutQuantity = (rule, value, callback, param) => {
      if (!value) {
        return callback(new Error(""));
      }
      if (!isAccord(value)) {
        callback(new Error(""));
      } else {
        callback();
      }
    };
    return {
      // 遮罩层
      loading: false,

      //初始化状态
      initialStatus: false,

      // 进入表单模式，有参、无参
      entryMode: false,

      //进入表单参数
      entry: {
        //记录编辑查看物料编码
        seeCode: "",
        //记录当前路由信息用于关闭当前页面
        routeMsg: {},
        //记录时间戳,用于是否刷新当前页面
        timeStamp: "",
      },

      //表单状态-addStatus:新增状态,seeStatus:查看状态,updateStatus:编辑状态
      fmStatus: "",

      //数据表单
      fmData: {},

      //选项
      option: {
        //按钮是否禁用
        btnIsClick: false,
        //输入框是否禁用
        disabledInput: false,
        //业务类型是否可更改
        wmworkStatus: false,
        //上一条下一条状态
        stripStatus: false,
        // 物料信息状态
        parametersStatus: false,
        //生产日期弹框状态
        arrangeDateDialog: false,
      },

      //枚举
      enums: {
        //单据类型
        optionsInvoiceType: [],
        selectInvoiceType: "",
        //标准工序
        optionsoperate: [],
      },

      //执行中
      stack: {
        //加工标准工序
        prsStatus: false,
        //点击选择物料记录下标，用于更新物料信息
        rowIndex: "",
        // 引入信息
        optionsImportMaterial: [],
        ImportMaterialStatus: false,
      },

      //样式
      style: {
        // 展开收起
        isToggle: true, //状态
        downTitle: "收起", //按钮辩题
        tableHeight: null, //物料信息高度
        // 展开收缩
        extendStatus: false,
        extendTitile: "收缩",
        successHide: false,
      },

      //打印
      print: {
        //打印组件状态
        printStatus: false,
        //打印数据
        printData: {},
        //打印名称
        printTitle: "",
        //二维码内容
        qrCodeValue: "",
        //打印部门
        printWorkDept: [],
      },

      //内存优化
      objPrinter: this.classPrinter(), //打印
      objHelper: this.classHelper(), //助手
      objUtils: this.classUtils(), //工具
      objFilling: this.classFilling(), //标准工序
      rules: {
        //是否必须输入
        invoiceDate: [
          {
            required: true,
            trigger: "change",
          },
        ],
        name: [
          {
            required: true,
            trigger: "blur",
          },
        ],
        duration: [
          {
            validator: checkOutDuration,
            required: true,
            trigger: "blur",
          },
        ],
        duration2: [
          {
            validator: checkOutDuration2,
            required: true,
            trigger: "blur",
          },
        ],
        arrangeDate2: [
          {
            validator: checkOutArrangeDate2,
            required: true,
            trigger: "change",
          },
        ],
        ppNumber: [
          {
            required: true,
            trigger: "change",
          },
        ],
        arrangeDate: [
          {
            required: true,
            trigger: "change",
          },
        ],
        operate: [
          {
            required: true,
            trigger: "change",
          },
        ],
        mpOrderCode: [
          {
            required: true,
            trigger: "change",
          },
        ],
      },
    };
  },
  activated() {
    //参数是否有值
    if (this.initialStatus == true) {
      this.initialStatus = false;
      return;
    }
    if (
      this.entry.timeStamp !== this.$route.query.timeStamp &&
      this.$route.query.open == "addStatus"
    ) {
      this.Initial();
      return;
    }

    if (this.entry.seeCode !== this.$route.query.detailCode) {
      if (
        this.fmStatus == "seeStatus" &&
        this.$route.query.open !== "addStatus"
      ) {
        this.Initial();
        return;
      }
    }
  },

  created() {
    //初始化页面
    this.initialStatus = true;
    this.Initial();
  },
  methods: {
    Initial() {
      // 按钮状态
      this.fmStatus = this.$route.query.open;
      this.entry.timeStamp = this.$route.query.timeStamp;
      if (this.fmStatus == "addStatus") {
        //新增状态重置表单
        this.objHelper.handleReset();
      }

      if (this.fmStatus == "seeStatus" || this.fmStatus == "updateStatus") {
        this.entry.seeCode = this.$route.query.detailCode;
        seeBill({
          processCode: this.entry.seeCode,
        }).then((res) => {
          if (res.code == 200) {
            this.fmData = res.data;
            if (this.fmStatus == "seeStatus") {
              this.option.disabledInput = true;
            } else {
              this.option.disabledInput = false;
            }
          }
        });
      }

      // 路由信息用于关闭页面
      this.entry.routeMsg = this.$route;
      this.objFilling.materialMaxHeight();
    },

    //确定新增
    btnNew(fmData) {
      if (this.fmData.prsProcessSectionList.length == 0) {
        this.msgError("请选择工序");
        return;
      }
      console.log(fmData);
      this.$refs.fmData.validate((valid) => {
        if (valid) {
          fmData.invoiceDate = this.parseTime(fmData.invoiceDate);
          addBill(fmData)
            .then((res) => {
              this.msgSuccess("新增成功");
              // 更新成功不刷新,重新赋值表单数据
              this.option.btnIsClick = true;
              this.fmStatus = "seeStatus";
              this.option.disabledInput = true;
              this.fmData = res.data;
              this.option.wmworkStatus = true;
              this.$store.dispatch("productionStatus/setProcessRefresh", true);
              this.objFilling.materialMaxHeight();
            })
            .catch((err) => {
              this.msgError("新增失败");
            });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },

    // 更新保存
    btnSave(fmData) {
      this.$refs.fmData.validate((valid) => {
        if (valid) {
          fmData.invoiceStatus = "0";
          fmData.invoiceDate = this.parseTime(fmData.invoiceDate);
          updateBill(fmData)
            .then((res) => {
              this.msgSuccess("更新成功");
              this.fmStatus = "seeStatus";
              this.option.disabledInput = true;
              this.fmData = res.data;
              this.option.wmworkStatus = true;
              this.$store.dispatch("productionStatus/setProcessRefresh", true);
              this.objFilling.materialMaxHeight();
            })
            .catch((err) => {
              this.msgError("更新失败");
            });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },

    //查看->编辑
    btnEdit() {
      this.option.disabledInput = false;
      this.fmStatus = "updateStatus";
      this.option.btnIsClick = false;
      if (this.entryMode == true) {
        this.option.wmworkStatus = true;
      } else {
        this.option.wmworkStatus = false;
      }
      this.objFilling.materialMaxHeight();
    },

    //查看->新增
    btnAdd(type) {
      if (type == "view") {
        this.$router.push({
          path: "/prs/production/processadd",
          query: {
            open: "addStatus",
            timeStamp: new Date().getTime(),
          },
        });
      } else {
        this.fmStatus = "addStatus"; //按钮状态为新增
        this.option.disabledInput = false; //输入框可输入
        this.option.btnIsClick = false; //按钮状态为可点击
        this.objHelper.handleReset(); //重置表单默认值

        if (this.entryMode == true) {
          this.option.wmworkStatus = true;
        } else {
          this.option.wmworkStatus = false;
        }
        this.$refs.fmData.clearValidate();
      }
    },

    //撤回
    btnUndo() {
      this.option.disabledInput = true; //是否可编辑
      this.workStatus = true;
      this.fmStatus = "seeStatus";
      this.option.disabledInput = true;
      this.option.wmworkStatus = true;
    },

    //新增->取消
    btnCancel() {
      const self = this;
      self.$store
        .dispatch("tagsView/delView", self.entry.routeMsg)
        .then(({ visitedViews }) => {
          let cancelFun = {
            isActive(route) {
              return route.path === self.$route.path;
            },
            toLastView(visitedViews, view) {
              const latestView = visitedViews.slice(-1)[0];
              if (latestView) {
                self.$router.push(latestView.fullPath);
              } else {
                if (view.name === "Dashboard") {
                  self.$router.replace({
                    path: "/redirect" + view.fullPath,
                  });
                } else {
                  self.$router.push("/");
                }
              }
            },
          };
          if (cancelFun.isActive(this.entry.routeMsg)) {
            cancelFun.toLastView(visitedViews, this.entry.routeMsg);
          }
        });
    },

    //审核
    btnCheck() {
      examineBill([
        {
          processCode: this.fmData.processCode,
        },
      ]).then((res) => {
        if (res.code == 200) {
          this.fmData.invoiceStatus = "1";
          this.fmData.checkDate = res.data.checkDate;
          this.fmData.userCheck = res.data.userCheck;
          this.$store.dispatch("productionStatus/setProcessRefresh", true);
          this.msgSuccess("审核成功");
        }
      });
    },

    //反审核
    btnUnCheck() {
      this.$confirm("确定撤销审核", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          return examineDeBill([
            {
              processCode: this.fmData.processCode,
            },
          ]);
        })
        .then((res) => {
          if (res.code == 200) {
            this.fmData.invoiceStatus = "2";
            this.fmData.checkDate = "";
            this.fmData.userCheck = "";
            this.$store.dispatch("productionStatus/setProcessRefresh", true);
            this.msgSuccess("撤销成功");
          }
        });
    },

    // 上一条下一条
    btnForward(code, type) {
      if (type == "next") {
        this.option.stripStatus = true;
        NextBill({
          processCode: code,
          type: true,
        })
          .then((res) => {
            if (res.code == 200) {
              this.fmData = res.data;
              this.option.parametersStatus = true;
              this.getDictionaryType();
              this.option.stripStatus = false;
            }
          })
          .catch((err) => {
            this.option.parametersStatus = true;
            this.option.stripStatus = false;
          });
      } else {
        this.option.stripStatus = true;
        NextBill({
          processCode: code,
          type: false,
        })
          .then((res) => {
            if (res.code == 200) {
              this.fmData = res.data;
              this.option.parametersStatus = true;
              this.getDictionaryType();
              this.option.stripStatus = false;
            }
          })
          .catch((err) => {
            this.option.parametersStatus = true;
            this.option.stripStatus = false;
          });
      }
    },

    //标准工序
    classFilling() {
      const self = this;
      return {
        // 最大高度
        materialMaxHeight() {
          if (`${document.documentElement.clientHeight}` - 460 < 400) {
            self.style.tableHeight = 500;
          } else {
            if (self.fmStatus == "seeStatus") {
              self.style.tableHeight =
                `${document.documentElement.clientHeight}` - 405;
            } else {
              self.style.tableHeight =
                `${document.documentElement.clientHeight}` - 390;
            }
          }
        },
        operateView() {
          self.stack.prsStatus = true;
        },
        handleOperateSelect(data) {
          let selectObj = {
            code: data[0].code,
            name: data[0].name,
            duration: data[0].duration,
            isQuality: data[0].isQuality,
            countType: data[0].countType,
            orderId: 0,
          };
          //加工标准工序
          if (data[1] == false) {
            // 更新表单数据
            self.fmData.prsProcessSectionList.push({ ...selectObj });
            self.stack.prsStatus = false;
          } else {
            self.fmData.prsProcessSectionList.push({ ...selectObj });
          }
        },

        selectOperateClose() {
          self.stack.prsStatus = false;
        },
      };
    },

    //打印
    classPrinter() {
      const self = this;
      return {
        //打印
        handlePrint() {
          let transferData = JSON.parse(JSON.stringify(self.fmData));
          self.print.qrCodeValue = `code=${transferData.processCode}`;

          //仓库
          self.enums.optionswarehouse.forEach((obj) => {
            if (obj.code == transferData.warehouse) {
              transferData.warehouse = obj.name;
            }
          });
          //业务状态
          self.enums.optionsworkStatus.forEach((obj) => {
            if (obj.dictValue == transferData.workStatus) {
              transferData.workStatus = obj.dictLabel;
            }
          });
          self.print.printData = transferData;
          self.print.printData.printTime = self.parseTime(new Date());
          self.print.printStatus = true;
          setTimeout(() => {
            this.getTitle().then(() => {
              self.$print(self.$refs.startPrint.$refs.print);
            });
          }, 50);
        },
        //获取模块参数中对应的打印标题
        getTitle() {
          return new Promise((resolve) => {
            moduleParameters({
              moduleId: "sys",
            })
              .then((res) => {
                if (res.code == 200) {
                  const obj = res.rows.find((item) => {
                    return item.configKey == "sys.title.print";
                  });
                  self.print.printTitle = obj.configValue;
                  resolve();
                }
              })
              .catch(() => {
                self.msgError("获取模块参数失败");
              });
          });
        },
      };
    },

    //助手
    classHelper() {
      const self = this;
      return {
        //收起
        downToggle() {
          self.stack.saveIndex = null;
          if (self.style.downTitle == "收起") {
            self.style.downTitle = "展开";
          } else {
            self.style.downTitle = "收起";
          }
          self.style.isToggle = !self.style.isToggle;
          if (self.style.isToggle == false) {
            self.style.tableHeight = parseInt(self.style.tableHeight) + 170;
          } else {
            self.style.tableHeight =
              `${document.documentElement.clientHeight}` - 440;
          }
        },

        //点击新增/查看新增重置表单
        handleReset() {
          self.fmData = {
            processCode: "", //单据编码
            invoiceDate: new Date(), //单据日期
            invoiceStatus: "0", //单据状态
            checkDate: "", //审核日期
            userCheck: "",
            name: "",
            orderId: 0,
            remarks: "",
            prsProcessSectionList: [],
          };
          /* 初始化状态 */
          self.option.disabledInput = false;
        },
      };
    },

    //工具
    classUtils() {
      const self = this;
      return {
        //时间格式转换
        inMaterTime(date) {
          let time = new Date(date);
          return (
            time.getFullYear() +
            "-" +
            (time.getMonth() + 1) +
            "-" +
            time.getDate() +
            " "
          );
        },
      };
    },
  },

  filters: {
    getInvoice(status) {
      switch (status) {
        case "0":
          return "开立";
          break;
        case "1":
          return "审核";
          break;
        case "2":
          return "退回";
          break;
        default:
          return "无";
      }
    },
  },
  components: {
    selectMaterial,
    selectImportMaterial,
    selectOperate,
    PrintPage,
  },
  watch: {},
};
</script>

<style lang="scss">
.menu-drop-box {
  .el-dropdown-menu__item {
    width: 90px;
    text-align: center;
    position: relative;

    span {
      display: inline-block;
    }

    i {
      position: absolute;
      left: 15px;
      top: 7px;
    }
  }

  .active {
    i,
    span {
      color: #46a6ff;
    }
  }
}

.prs-process-box {
  .el-input-number--medium {
    width: 210px;
  }
  .mb-mbom {
    padding: 15px 20px 20px 20px;
    box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
    .piece-box {
      i {
        display: none;
      }
    }
    .cell {
      overflow: hidden !important;
    }
  }

  .el-textarea__inner {
    font-size: 14px;
    color: #303133;
    padding: 5px 10px !important;
  }

  .quality-box {
    p {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      width: 190px;
      margin: 0 5px;
    }
  }
  .drop-menu {
    position: absolute;
    width: 210px;
    box-shadow: 1px 1px 5px 1px #eee;
    max-height: 500px;
    overflow: auto;
    z-index: 9;
    background: #fff;
    left: 70px;
    top: 35px;
    color: #606266;

    p {
      padding: 10px;
      text-align: center;
      width: 100%;
      color: #606266;
    }

    .menu-close {
      position: sticky;
      top: 0;
      width: 210px;
      text-align: right;
      height: 30px;
      background: #fff;
      line-height: 30px;
      border-bottom: 1px solid #eee;

      .search-top {
        display: flex;
        justify-content: space-between;
        align-items: center;

        span {
          font-size: 14px;
          margin-left: 10px;
          color: #606266;
        }
      }

      a {
        padding-right: 10px;
        font-size: 14px;
      }
    }

    .ma-list {
      .list-t {
        text-align: left;
        cursor: pointer;
        border-bottom: 1px solid #eee;
        font-size: 14px;
        padding-top: 5px;
        padding-bottom: 5px;

        &:hover {
          background-color: #f5f7fa;
        }

        .po-content {
          display: flex;
          align-items: center;
        }

        span {
          display: inline-block;
          margin-left: 10px;
          margin-right: 10px;
        }
      }
    }
  }

  .el-textarea.is-disabled .el-textarea__inner {
    color: #333;
  }

  .purchas-information {
    .el-card__body {
      padding: 15px 20px 10px 20px;
    }

    .el-input__inner,
    .el-textarea__inner {
      width: 210px;
    }
  }

  .set-location {
    display: flex;
    align-items: center;

    .location-btn {
      flex-shrink: 1;
      width: 40px;
      margin-right: 5px;
      height: 20px;
    }
  }

  .el-card.is-always-shadow {
    overflow: inherit;
  }

  .unfold-way {
    display: flex;
    justify-content: space-between;
    width: 100%;
    align-items: center;

    p {
      margin: 0;
      margin-bottom: 8px;
    }
  }

  .con-spec {
    display: flex;
    text-align: center;
    justify-content: center;
    word-wrap: break-word;

    .spec-l {
      padding-right: 2px;

      input {
        text-align: right !important;
      }
    }

    .spec-r {
      input {
        text-indent: 0 !important;
        text-align: left !important;
      }
    }
  }

  .el-radio__input.is-disabled.is-checked .el-radio__inner {
    border-color: #1890ff;
    background: #1890ff;
  }

  .el-radio__input.is-disabled + span.el-radio__label {
    color: #333;
  }

  .info-list {
    .articles-numbers {
      margin-bottom: 5px;
      text-align: right;

      a {
        font-size: 14px;
        margin-left: 15px;
        color: #1890ff;

        &:hover {
          opacity: 0.7;
        }
      }
    }

    .wn-in-box {
      display: flex;
    }

    .list-box {
      .box-input {
        display: flex;
        margin-right: 30px;
        align-items: center;
        margin-bottom: 5px;
        position: relative;

        .input-select {
          margin-left: 5px;
        }

        p {
          flex-shrink: 0;
          width: 70px;
          font-size: 14px;
          margin: 0px;
        }

        .el-input {
          width: auto;
          flex: 1;
        }

        .el-textarea {
          width: 100%;
          flex: 1;
        }

        .drop-menu {
          position: absolute;
          width: 212px;
          box-shadow: 1px 1px 5px 1px #eee;
          max-height: 120px;
          overflow: auto;
          z-index: 9;
          background: #fff;
          left: 70px;
          top: 35px;
          color: #606266;

          p {
            padding: 10px;
            text-align: center;
            width: 100%;
            color: #606266;
          }

          .menu-close {
            position: sticky;
            top: 0;
            width: 212px;
            text-align: right;
            height: 30px;
            background: #fff;
            line-height: 30px;
            border-bottom: 1px solid #eee;

            .search-top {
              display: flex;
              justify-content: space-between;
              align-items: center;

              span {
                font-size: 14px;
                margin-left: 10px;
                color: #606266;
              }
            }

            a {
              padding-right: 10px;
              font-size: 14px;
            }
          }

          .ma-list {
            .list-t {
              text-align: left;
              cursor: pointer;
              border-bottom: 1px solid #eee;
              font-size: 14px;
              padding-top: 5px;
              padding-bottom: 5px;

              &:hover {
                background-color: #f5f7fa;
              }

              .po-content {
                display: flex;
                align-items: center;
              }

              span {
                display: inline-block;
                margin-left: 10px;
                margin-right: 10px;
              }
            }
          }
        }
      }
    }

    .el-input.is-disabled .el-input__inner {
      color: #333;
    }

    .blue-color .is-disabled .el-input__inner {
      color: #1890ff;
    }
  }

  .purchas-content {
    margin-top: 10px;

    .el-table--border {
      border-left: 1px solid #dfe6ec;
    }
    .el-card__body {
      padding: 0;
    }
    .el-textarea__inner {
      border: none;
    }

    .el-textarea.is-disabled .el-textarea__inner {
      background: none;
    }

    .el-table__row td:first-child,
    .has-gutter th:first-child {
      border-left: none;
    }

    .clearfix {
      p {
        margin: 0;
        margin-bottom: 8px;
      }
    }

    .el-card__header {
      padding-right: 20px;
    }

    .el-input__inner {
      height: 31px;
      line-height: 0;
      padding: 0 5px;
      color: #606266;
    }

    .el-input__icon {
      line-height: 0;
    }

    .el-table .cell {
      overflow: inherit;
    }

    .select-name {
      display: flex;
      align-items: center;

      .el-input {
        flex: 1;
      }

      span {
        line-height: 20px;
        margin-left: 5px;
        font-size: 14px;
        margin-right: 5px;
      }
    }

    .table-data {
      .el-table__body-wrapper {
        overflow: auto;

        .cell {
          height: auto !important;
        }
      }

      .el-table .el-table__header-wrapper th,
      .el-table .el-table__fixed-header-wrapper th {
        height: 35px !important;
      }

      .cell {
        padding: 0;
      }

      .el-input--medium .el-input__inner {
        background: none;
        border-color: #fff;
        border-radius: 0;
        padding: 0;
        text-align: center;
      }

      .el-form-item.is-error .el-input__inner,
      .el-form-item.is-error .el-input__inner:focus,
      .el-form-item.is-error .el-textarea__inner,
      .el-form-item.is-error .el-textarea__inner:focus {
        border-color: #ff4949;
      }

      .el-table--enable-row-hover .el-table__body tr:hover > td {
        background: none;
      }

      .el-table--medium th,
      .el-table--medium td {
        padding: 0 !important;
        text-align: center;
      }

      .el-form-item--medium .el-form-item__content {
        line-height: 30px;
      }

      .add-icon {
        margin-top: 5px;
        text-align: center;
      }
    }

    .el-form-item__error {
      padding-top: 0;
      top: 90%;
    }
  }

  .save-btn {
    margin: 20px;

    button {
      width: 200px;
    }
  }

  .el-form-item {
    margin-bottom: 0;
  }

  .button-plan span {
    display: inline-block;

    button {
      margin-left: 10px;
    }
  }

  .invoice-box {
    background-color: #f5f7fa;
    border-color: #dfe4ed;
    width: 100%;
    padding: 0px 15px;
    height: 32px;
    line-height: 27px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    margin-bottom: 3px;
    margin-top: 3px;

    span {
      font-size: 14px;
    }
  }

  .text-right {
    input {
      text-align: right !important;
      padding-right: 10px !important;
    }

    span {
      display: inline-block;
      padding-right: 10px;
      width: 100%;
      text-align: right;
    }
  }

  .select-box {
    position: relative;

    .drop-menu1 {
      position: absolute;
      width: 395px;
      box-shadow: 1px 1px 5px 1px #eee;
      max-height: 300px;
      overflow: auto;
      z-index: 9;
      background: #fff;

      .menu-close {
        position: sticky;
        top: 0;
        width: 380px;
        text-align: right;
        height: 30px;
        background: #fff;
        line-height: 30px;

        .search-top {
          display: flex;
          justify-content: space-between;
          align-items: center;

          span {
            font-size: 14px;
            margin-left: 10px;
          }
        }

        a {
          padding-right: 10px;
        }
      }

      .ma-list {
        margin-bottom: 10px;

        .list-t {
          text-align: left;
          cursor: pointer;
          border-bottom: 1px solid #eee;
          font-size: 14px;

          &:hover {
            background-color: #f5f7fa;
          }

          span {
            display: inline-block;
            margin-left: 10px;
            margin-right: 10px;
          }
        }
      }
    }
  }

  .matrial-box .basicfile-box .cell {
    height: auto !important;
  }

  .el-card__header {
    padding-right: 20px;
  }
}
</style>
